Repository navigation
feat(sdk): add settings file and layered resolver for targets, platforms and secret stores - #690
Merged
Merged
Conversation
…re, with a layered resolver .metaobjects/settings.json, read by TypeScript only (ADR-0070, calls 5 and 13): targets, platforms, resourceDefaults keyed by platform then kind, purposes, environments and secrets.stores, with an extends chain merged key by key. The resolver answers which target, product, size and secret store a node gets, and which layer and file each value came from. The design's three complete setup files are test fixtures and resolve as written.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Changed
.metaobjects/settings.json, read by TypeScript only. It carriestargets,platforms,resourceDefaults(keyed by platform, then resource kind),purposes,environmentsandsecrets.stores. It mayextendsa shared estate file (relative path or package), merged key by key with the nearer file winning.config.jsongains no keys.@metaobjectsdev/sdkexportsloadSettings,loadSettingsFile, theSettingsFileSchemaand aSettingsErrorwith stable error codes. It also exports a resolver (resolveTarget,resolveResource,resolveApp,resolveGeneratedStore,resolveAdoptedStore) that reports each value with the layer and file it came from. Layers are generator default, resource defaults, purpose, then environment.test/fixtures/settings/setup-{a,b,c}.settings.json) that parse and resolve. Addsdocs/features/settings.md, adocs/README.mdindex entry, and a changelog fragment. The feature is experimental. No generator reads the settings yet, and a project without a settings file sees no change.metamodelVersiondoes not move.Validation
Risk Assessment
✅ Low: Additive TypeScript-only settings reader and resolver with no generator consumers yet. The round-1 gaps (platform-key checks, Object.prototype lookups) are closed with tests, and the intent's required layers, three setup files and
extendsare all present.Testing
Ran the S1 settings unit tests (24 pass) and a live bun driver against the real sdk loader and resolver. The three setup files load, layer precedence resolves as specified, the review-1 typo refusals fire, prototype names do not resolve, and extends overrides key by key. All scenarios passed live against local fixtures. Broad regression came from the configured baseline command, which passed. The review-2 question was decided:
extendskeeps the package-specifier mode, because shared estate settings live in another repository; that mode and its not-found branch are covered by the unit tests.Evidence: Settings resolver live driver log
Pipeline
Updates from git push no-mistakes
✅ **Intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 2 issues found → auto-fixed ✅
server/typescript/packages/sdk/src/settings.ts:302- checkNames validates only some of the keys that name a platform. A target'splatformand thesecrets.targetskeys are checked. TheresourceDefaultsplatform keys and thesecrets.generatedplatform keys are not checked. A typo such asresourceDefaults.dokcer.rdborsecrets.generated.dokcerloads clean. Then resolveResource silently falls back to the generator default product and version (settings.ts:440-441), and resolveGeneratedStore silently returns undefined (settings.ts:487-489). Both give a wrong answer without an error, which is the typo trap the schema comment at settings.ts:60-63 says the file guards against. Related problem: all membership tests use theinoperator (settings.ts:305, :321, :326), which also matches Object.prototype names. A platform, store or target namedconstructorortoStringpasses the check, and the resolver then reads a function fromdata.platforms[...],secrets.stores[...]ordata.targets[...](settings.ts:385, :392, :489, :496). Fix: in checkNames, refuse aresourceDefaultskey orsecrets.generatedkey that is not underplatforms, with ERR_SETTINGS_UNKNOWN_PLATFORM. Use Object.hasOwn for every membership test. All three setup fixtures already satisfy the stricter check. Add a test case for each new refusal.server/typescript/packages/sdk/src/settings.ts:232- Simplification:extendsaccepts two resolution modes. One is a path relative to the extending file. The other is a bare package specifier, resolved through createRequire(fromFile).resolve (settings.ts:240-247, tested at settings.test.ts:216, documented in docs/features/settings.md). The intent asks only forextendsto a shared estate file that a project extends. A relative path satisfies that. The package-specifier mode adds a node_modules resolution path, a second failure branch, and a public contract that is beyond what the stated scope requires, unless the round-1 layering design calls for package-published estate files. That design is not in the repository, so this review could not confirm it. Recommend removing the package-specifier mode unless the design requires it.🔧 Fix applied.
✅ Re-checked - no issues remain.
✅ **Test** - passed (review-2 decided by the operator)
extends(the review-2 ruling); approved by the operator.scripts/ci-local.sh --affected --strict-toolchainsbun test packages/sdk/test/settings.test.ts (in server/typescript): 24 pass, 0 failLive bun driver importing packages/sdk/src/index.ts: loadSettingsFile on setup-a, setup-b, setup-c fixturesPrecedence: resolveResource on setup-b aws-eu-west rdb across generator, resourceDefaults, purpose and environment layersAdversarial: resourceDefaults key dokcer and secrets.generated key dokcer refused with ERR_SETTINGS_UNKNOWN_PLATFORMAdversarial: resolveTarget(toString) refused with ERR_SETTINGS_UNKNOWN_TARGETextends: project overrides estate key by keyEnvironment precedence: provisions.db1 version 18 over purpose 17 over resourceDefaults 16Broad regression: configured command scripts/ci-local.sh --affected --strict-toolchains at this target, passing (baseline; not re-run)✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.